﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace mal.balades.Web.Controls
{
    public partial class GoogleAdSense : System.Web.UI.UserControl
    {
        private List<AdSenseConfiguration> configurations;
        private AdSenseConfiguration configuration;
        private AdSenseBlockType block = AdSenseBlockType.Small;

        protected void Page_Load(object sender, EventArgs e)
        {
            configurations = new List<AdSenseConfiguration>();

            configurations.Add(new AdSenseConfiguration() { Block = AdSenseBlockType.Small, Slot = "5793234865", Width = 300, Height = 250 });
            configurations.Add(new AdSenseConfiguration() { Block = AdSenseBlockType.Big, Slot = "7909948963", Width = 336, Height = 280 });
            configurations.Add(new AdSenseConfiguration() { Block = AdSenseBlockType.Rectangle, Slot = "4271757085", Width = 468, Height = 60 });
            
            var query = from c in configurations
                        where c.Block == block
                        select c;

            configuration = query.FirstOrDefault();
        }

        public AdSenseBlockType Block
        {
            set
            {
                block = value;

               
            }
        }

        protected AdSenseConfiguration Configuration
        {
            get
            {
                return configuration;
            }
        }

        public enum AdSenseBlockType
        {
            Small,
            Big,
            Rectangle
        }

        public class AdSenseConfiguration
        {
            public AdSenseBlockType Block { get; set; }			
            public string Slot { get; set; }
            public int Width { get; set; }
            public int Height { get; set; }
        }
    }
}